richtext edition

Hello,

 

I try to suppress some "tags" in object texts. These object texts have some richtexts as bullets or underlined, or bold texts.

The macro is running just after an import from Word.

Here is my code :

Module m = current Module
for obj in m do
{
int offset = 0
int l= 0
string s = obj."Object text"
string sub = "REQUIREMENT_xxx : "
int t = length sub 
print taille " "
if(findPlainText(s, sub, offset, l, true)) {
obj."Object Text" = s [offset+t:] ""
obj."AS Exigence" = "TRUE"
}
}

Running this code suppress all richtext : there is no more bold, underlined or bulleted text.

 

So I tried to have some richtext by string s = richText (obj."Object Text") but the result is unreadable : there are all tags of richtexts.

 

How can I just suppress the "REQUIREMENT_xxx : " from the objects keeping richtext readable ?

 

Estebell


Estebell - Thu Jun 01 03:06:11 EDT 2017

Re: richtext edition
Mathias Mamsch - Thu Jun 01 04:42:32 EDT 2017

First you need to read richtext: 

string s = richTextWithOle obj."Object text"

then afterwards you need to write richtext: 

obj."Object Text" = richText s [offset+t:] ""

Regards, Mathias

Re: richtext edition
Estebell - Thu Jun 01 05:07:24 EDT 2017

If I replace these 2 lines, I have an error  line 11 :

The string is not in rich text format.

 

Regards

Re: richtext edition
Mathias Mamsch - Thu Jun 01 05:21:27 EDT 2017

Estebell - Thu Jun 01 05:07:24 EDT 2017

If I replace these 2 lines, I have an error  line 11 :

The string is not in rich text format.

 

Regards

I see, you want to replace the text inside the richtext string. I did not register the "s [offset+t:]". So you want everything after some text?

Maybe you could simply replace that part? Then this code could help: 

https://www.ibm.com/developerworks/community/forums/html/topic?id=ed415d55-3a15-4792-9dad-147d609cf878&ps=25

Regards, Mathias

Re: richtext edition
Estebell - Thu Jun 01 06:00:15 EDT 2017

Mathias Mamsch - Thu Jun 01 05:21:27 EDT 2017

I see, you want to replace the text inside the richtext string. I did not register the "s [offset+t:]". So you want everything after some text?

Maybe you could simply replace that part? Then this code could help: 

https://www.ibm.com/developerworks/community/forums/html/topic?id=ed415d55-3a15-4792-9dad-147d609cf878&ps=25

Regards, Mathias

Yes it works !

Thant's to your link to the other topic.

 

Regards

Estebell